var request = require('superagent');
var API = require('./support/const');
var service = require('../../service/log');

/**
 * 申请注册列表
 */

exports.unitSignupList = function (req, res, next) {
    let header = {
        token: req.cookies.token
    };
    request.get(API.unit_signup.unit_signup_list)
        .set(header)
        .query({msg: JSON.stringify(req.body)})
        .end(function (_req, _res) {
            if (_res.status === 200) {
                service.save_user_log({'type': 'getList', 'msg': '获取申请注册列表'}, req);

                res.json(JSON.parse(_res.text));
            }else{
                res.json(_res)
            }

        });
};
/**
 * 申请注册审核
 */

exports.unitSignupAudit = function (req, res, next) {
    let header = {
        token: req.cookies.token
    };
    request.put(API.unit_signup.unit_signup_audit)
        .set(header)
        .query({msg: JSON.stringify(req.body)})
        .end(function (_req, _res) {
            if (_res.status === 200) {
                service.save_user_log({'type': 'edit', 'msg': '审核注册列表'}, req);

                res.json(JSON.parse(_res.text));
            }else{
                res.json(_res)
            }

        });
};
/**
 * 更新信息
 */

exports.unitSignupUpdate = function (req, res, next) {
    let header = {
        token: req.cookies.token
    };
    request.put(API.unit_signup.unit_signup_update)
        .set(header)
        .query({msg: JSON.stringify(req.body)})
        .end(function (_req, _res) {
            if (_res.status === 200) {
                service.save_user_log({'type': 'edit', 'msg': '更新注册信息'}, req);

                res.json(JSON.parse(_res.text));
            }else{
                res.json(_res)
            }

        });
};
